package com.example.demo.config;

import com.example.demo.entity.BatchPeople;
import com.example.demo.entity.User;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowFact;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;

/**
 * @ClassName CmpConfig
 * @Description:
 * @Author: hgq
 * @CreateDate: 2025/2/21 15:05
 * @UpdateUser: hgq
 * @UpdateDate: 2025/2/21 15:05
 * @UpdateRemark:
 * @Version: 1.0
 */
@LiteflowComponent
public class CmpConfig {

    //普通组件的定义
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a", nodeName = "A组件")
    public void processA(NodeComponent bindCmp) {
        User user = (User) bindCmp.getRequestData();
        System.out.println("====");
        System.out.println(user.toString());
        System.out.println("AAAAAAAAAAAAAA");
    }
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a1", nodeName = "A组件")
    public void processA1(NodeComponent bindCmp) {
        System.out.println("1122222222222AAAAAAAAAAAAAA");
    }
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a2", nodeName = "A组件")
    public void processA2(NodeComponent bindCmp) {
        System.out.println("222222222222222AAAAAAAAAAAAAA");
    }

    //SWITCH组件的定义
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH, nodeId = "b", nodeName = "B组件", nodeType = NodeTypeEnum.SWITCH)
    public String processB(NodeComponent bindCmp) {
        System.out.println("BBBBBBBBBBBBBBBBBBBBBB");
        return "b";
    }

    //布尔组件的定义
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "c", nodeName = "C组件", nodeType = NodeTypeEnum.BOOLEAN)
    public boolean processC(NodeComponent bindCmp, @LiteflowFact("batchPeople.batchNo") String batchNo) {
        System.out.println("CCCCCCCCCCCCCCCCCCCCC");
        User user = (User) bindCmp.getRequestData();
        System.out.println("====");
        System.out.println(user.toString());
        user.setUserName(user.getUserName() + "111");
        System.out.println("-----------------------------");
        BatchPeople batchPeople = bindCmp.getContextBean(BatchPeople.class);
        System.out.println(batchPeople);
        System.out.println("batchNo:" + batchNo);
        System.out.println("========================");
        return true;
    }

    //FOR组件的定义
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_FOR, nodeId = "d", nodeName = "D组件", nodeType = NodeTypeEnum.FOR)
    public int processD(NodeComponent bindCmp) {
        System.out.println("DDDDDDDDDDDDD");
        return 3;
    }

    //迭代组件的定义
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_ITERATOR, nodeId = "e", nodeName = "E组件", nodeType = NodeTypeEnum.ITERATOR)
    public int processE(NodeComponent bindCmp) {
        System.out.println("EEEEEEEEEEEEEEEE");
        return 5;
    }
}
